<?php
class notifier { 
	private static $notification = Array("info" => Array(), "debug" => Array(), "error" => Array(), "success" => Array()); 

	public static function add($msg, $type = "info"){ 
	  array_push(self::$notification[$type], $msg); 
	} 

	public static function show($type = "info"){ 
	  foreach(self::$notification[$type] as $error) echo $error."<br />"; 
	}

	public static function exists($type = "info"){ 
	   return count(self::$notification[$type]) > 0 ? true : false; 
	}
}

function notifications() {
	if ((notifier::exists("debug") && isset($_SESSION['debug'])) || notifier::exists("error") ) {
		echo "<div class=\"alert\">";
		if ($_SESSION['debug'] == "on") {
			notifier::show("debug");
		}
		notifier::show("error");
		echo "</div>";
	}
	
	if (notifier::exists("info")) {
		echo "<div class=\"info\">";
		notifier::show("info");
		echo "</div>";
	}
	
	if (notifier::exists("success")) {
		echo "<div class=\"success\">";
		notifier::show("success");
		echo "</div>";
	}
}
?>